<!DOCTYPE html>
<HTML>
<HEAD>
    <TITLE>代理商等级结构</TITLE>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="/statics/css/ztree_css/demo.css" type="text/css">
    <link rel="stylesheet" href="/statics/css/ztree_css/zTreeStyle/zTreeStyle.css" type="text/css">
    <script src="/statics/js/ztree_js/jquery-1.4.4.min.js"></script>
    <script src="/statics/js/ztree_js/jquery.ztree.core.js"></script>
</HEAD>
    <!--  <script type="text/javascript" src="../../../js/jquery.ztree.excheck.js"></script>
      <script type="text/javascript" src="../../../js/jquery.ztree.exedit.js"></script>-->
    <SCRIPT type="text/javascript">
        <!--
        var setting = {
            data: {
                simpleData: {
                    enable: true
                }
            },
            view: {
        		showIcon: showIconForTree,
        		fontCss: setFontCss
        	}	
        };
        function showIconForTree(treeId, treeNode) {
        	return treeNode.level == -1;
        };
        function setFontCss(treeId, treeNode) {
        	return treeNode.level == 0 ? {color:"red"} : {};
        };
        <?php
                function tree2html($list,$times=0)
                {
                    $separator = '&nbsp;&nbsp;';
                    for($i = 0; $i < $times; $i++){
                        $separator .= '&nbsp;&nbsp;';
                    }
                    foreach ($list as $row) {
                    ?>
                    { id:<?=$row['cust_id'];?>, pId:<?=$row['parent_id'];?>, open:'true', name:"<?=$row['salelevel'] == '1' ? '【店长】' : ($row['salelevel'] == '2' ? '【经理】' : ($row['salelevel'] == '3' ? '【总监】' : '非会员'))?><?=$row['cust_realname'];?>"},
                    <?php
                    if (!empty($row['list'])){
                        tree2html($row['list'],++$times);
                    }
                }
                }?>

            var zNodes =[
            <?php if($getData){foreach($getData AS $key=>$val){?>
                { id:<?=$val['cust_id'];?>, pId:<?=$val['parent_id']?>, name:"<?=$val['salelevel'] == '1' ? '【店长】' : ($val['salelevel'] == '2' ? '【经理】' : ($val['salelevel'] == '3' ? '【总监】人' : '非会员'))?><?=$val['cust_realname'];?>", open:true},
            <?php tree2html($val['list'],1); ?>

        <?php }} ?>
            ];



        $(document).ready(function(){
            $.fn.zTree.init($("#treeDemo"), setting, zNodes);
        });
        //-->
    </SCRIPT>
<body>
<div class="row-fluid" ><br>
<span style="color:red;padding-left:15px"><b>温馨提示：下面结构中的红色用户为 顶级代理</b></span>
<hr style="margin-top: 0px;margin-bottom: -13px;">
<div class="content_wrap" style="margin-left:25px">
    <div class="zTreeDemoBackground left">
        <ul id="treeDemo" class="ztree" style="width: 900px;height: auto; border: 0;background-color: transparent"></ul>
    </div>


</div>
</div>
    </body>
</HTML>